<?php

$userid         = get_loggedin_userid();
$client_id      = get_input('client_id');
$interestid     = get_input('interest_id');

$friendEntities = greengar_get_friends($userid, $client_id);

$result = array();
foreach ($friendEntities as $friendEntity) {
    $fId = $friendEntity->getGUID();
    
    $query_results = get_interest_ratings_of($fId);
    foreach($query_results as $query_result) {
        $ratingArray = to_rating_array($query_result);
        $ratingArray['user'] = userToArray($friendEntity, $client_id);
        $result[] = $ratingArray;
    }
}


echo json_encode(export_result(200, $result));

?>
